/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.fyx.linker.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author xljan
 */
@Entity
@Table(name = "linker_link")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = LinkerLink.NQ_REMOVE_ALL, query = 
        "DELETE FROM LinkerLink"),
    @NamedQuery(name = "LinkerLink.findAll", query = 
        "SELECT l FROM LinkerLink l"),
    @NamedQuery(name = "LinkerLink.findByIdLink", query = 
        "SELECT l FROM LinkerLink l WHERE l.idLink = :idLink"),
    @NamedQuery(name = LinkerLink.NQ_FIND_BY_ID_CATEGORY, query = 
        "SELECT l FROM LinkerLink l WHERE l.idCategory.idCategory = "
        + ":idCategory")})
public class LinkerLink implements Serializable {
    public static final String NQ_FIND_BY_ID_CATEGORY = 
            "LinkerLink.findByIdCategory";
    public static final String NQ_REMOVE_ALL = "LinkerLink.removeAll";
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "id_link")
    private String idLink;
    @Column(name = "priority")
    private Integer priority;
    @JoinColumn(name = "id_category", referencedColumnName = "id_category")
    @ManyToOne
    private LinkerCategory idCategory;

    public LinkerLink() {
    }

    public LinkerLink(String idLink) {
        this.idLink = idLink;
    }

    public String getIdLink() {
        return idLink;
    }

    public void setIdLink(String idLink) {
        this.idLink = idLink;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public LinkerCategory getIdCategory() {
        return idCategory;
    }

    public void setIdCategory(LinkerCategory idCategory) {
        this.idCategory = idCategory;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLink != null ? idLink.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof LinkerLink)) {
            return false;
        }
        LinkerLink other = (LinkerLink) object;
        if ((this.idLink == null && other.idLink != null) || 
                (this.idLink != null && !this.idLink.equals(other.idLink))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.fyx.linker.entity.LinkerLink[ idLink=" + idLink + " ]";
    }
    
}
